package com.easy.controller;

import cn.hutool.crypto.SecureUtil;
import cn.hutool.json.JSONUtil;
import com.easy.common.util.SignatureUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;


/**
 * 又拍云获取Signature
 * @author 风亦未止
 * @date 2021/10/5 18:36
 */
@Slf4j
@RestController
@RequestMapping("/getSignatureUrl")
public class SignatureController {
    private String PassWord="MdlLeY8oMoNw3hu5lXNesV3nUeg36ZPr";

    @GetMapping("/get")
    public String getSignature(@RequestParam("data") String data) throws Exception {
        log.info(data);
        String secret= SecureUtil.md5(PassWord);
        //注意填入值得顺序，key为密码 踩过坑
        String signature = SignatureUtil.HmacSHA1Encrypt(data,secret);
        return "{\"signature\":"+"\""+signature+"\""+"}";
    }
}
